<?php
/**
 * <p>Title: HTML Table generator</p>
 * <p>Description: Generates XHTML 1.0 Strict tables</p>
 * @author Oddleif Halvorsen
 * @version 1.0
 */

include_once("HTMLTag.php");

//This should really not extend HTMLTag since it is not a html tag, but
//it i practical to do it this way since it's childs will be html tags.
class TableCell extends HTMLTag{
	var $align;
	var $content;
	var $rowspan;
	var $colspan;

	/**
	 * Initiates a table cell
	 * @param $content The content for the cell. Default == &nbsp;
	 */
	function TableCell($content = "&nbsp;"){
		$this->align = NULL;
		$this->content = $content;
	}
	
	/**
	 * Specifies how the content of the cell is to be aligned
	 * @param $align left, right, center, justify, char
	 */
	function setAlign($align){ $this->align = $align;	}
	function setColspan($colspan){ $this->colspan = $colspan;	}
	function setRowspan($rowspan){ $this->rowspan = $rowspan;	}
	function setContent($content){ $this->content = $content;	}
	
	function getAlign(){ return (isset($this->align) ? $this->align : FALSE);	}
	function getColspan(){ return (isset($this->colspan) ? $this->colspan : FALSE);	}
	function getRowspan(){ return (isset($this->rowspan) ? $this->rowspan : FALSE);	}
	function getContent(){ return (isset($this->content) ? $this->content : FALSE);	}
	
	/**
	 * Returns the html attributes that is set, it also
	 * gets the parents attributes.
	 * @return A text string with the attributes on the form: ' attribute="value"'
	 */	 
	function getAttributes(){
		$attributes = "";
		if(parent::getAttributes() != FALSE)
			$attributes = parent::getAttributes();
		
		if($this->getAlign())
			$attributes .= " align=\"" . $this->getAlign() . "\"";
		if($this->getColspan())
			$attributes .=  " colspan=\"" . $this->getColspan() . "\"";
		if($this->getRowspan())
			$attributes .=  " rowspan=\"" . $this->getRowspan() . "\"";
		
		return (isset($attributes) ? $attributes : FALSE);
	}
}
?>